package operation; //操作图书的各种方法

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-08-23
 * Time: 21:46
 * name: 增加图书操作
 */
public class AddOperation implements IOperation{

    //添加功能

    @Override
    public void way(BookList bookList) {
        System.out.println("请添加图书！");
        System.out.println("请输入需要添加图书得名字：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入需要添加图书得作者:");
        String author = scanner.nextLine();
        System.out.println("请输入需要添加图书得类型：");
        String type = scanner.nextLine();
        System.out.println("请输入需要添加图书得价格：");
        double price = scanner.nextDouble();

        Book book = new Book(name, author, type, price);

        bookList.setBooks(book, bookList.getCountsize());

        //书籍添加后，书架增加一本书
        bookList.setCountsize(bookList.getCountsize() + 1);
        System.out.println("添加成功！");

    }
}
